﻿<%@ CODEPAGE=65001 %>
<% 'Option Explicit %>
<% 'On Error Resume Next %>
<% Response.Charset="UTF-8" %>
<% Response.Buffer=True %>
<!-- #include file="../../c_option.asp" -->
<!-- #include file="../../../zb_system/function/c_function.asp" -->
<!-- #include file="../../../zb_system/function/c_system_lib.asp" -->
<!-- #include file="../../../zb_system/function/c_system_base.asp" -->
<!-- #include file="../../../zb_system/function/c_system_plugin.asp" -->
<!-- #include file="../p_config.asp" -->
<!-- #include file="function.asp" -->

<%
Call System_Initialize()
Call Bcastr_Initialize

'检查非法链接
Call CheckReference("")

'检查权限
If BlogUser.Level>1 Then Call ShowError(6)
If CheckPluginState("Bcastr")=False Then Call ShowError(48)
%>
<html>
<head>
<meta name="robots" content="nofollow"/>
<title>插入图片</title>
<style>
#insert .ll{float:left;margin:2px 2px;border:1px solid #ccc;}#insert img{position:relative;width:250px;height:auto;overflow:hidden;}
</style>
</head>
<body>
<div id="insert">
<%
Dim from
from = Request.QueryString("from")

'镶入jquery和WindsPhoto中的jquery.masonry
If CheckPluginState("windsphoto")=True Then Response.write "<script src="""&ZC_BLOG_HOST&"/ZB_SYSTEM/script/common.js""></script><script src=""../windsphoto/script/jquery.masonry.min.js""></script><script>$(function(){var $container=$('#insert');$container.imagesLoaded(function(){$container.masonry({itemSelector:'.ll'})})});</script>"

Dim temprs,strSQL,strResponse,objArticle,strArticleUrl,strArticleTitle
If from = "article" Then
	If CheckRights("Root")=False Then strSQL=" And [log_AuthorID] = " & BlogUser.ID
	Set temprs=objConn.Execute("SELECT TOP 100 [log_ID],[log_Tag],[log_CateID],[log_Title],[log_Intro],[log_Content],[log_Level],[log_AuthorID],[log_PostTime],[log_CommNums],[log_ViewNums],[log_TrackBackNums],[log_Url],[log_Istop],[log_Template],[log_FullUrl],[log_Type],[log_Meta] FROM [blog_Article] WHERE [log_Level]=4 And [log_Type]=0" & strSQL & " ORDER BY [log_PostTime] DESC")
	Do While Not temprs.Eof
		Set objArticle=New TArticle
		If objArticle.LoadInfoByArray(Array(temprs(0),temprs(1),temprs(2),temprs(3),temprs(4),temprs(5),temprs(6),temprs(7),temprs(8),temprs(9),temprs(10),temprs(11),temprs(12),temprs(13),temprs(14),temprs(15),temprs(16),temprs(17)))  Then
			strArticleUrl=objArticle.Url
			strArticleTitle=objArticle.Title
			'strArticleUrl=replace(temprs("log_FullUrl"),"<#ZC_BLOG_HOST#>",ZC_BLOG_HOST)
			Response.write "<div><a href=""javascript:try{window.opener.document.getElementById('tmp_link').value='"&strArticleUrl&"';window.opener.document.getElementById('tmp_title').value='"&strArticleTitle&"'}catch(e){};window.close();"" title=""点击标题插入"">"&strArticleTitle&"</a></div>"& VBCRLF
		End If
		temprs.MoveNext
		Set objArticle=Nothing
	Loop
	Set temprs=Nothing
ElseIf from = "upload" Then
	If CheckRights("RegMng")=False Then strSQL="WHERE ([ul_AuthorID] = " & BlogUser.ID & ")"
	Set temprs=objConn.Execute("SELECT TOP 100 * FROM [blog_UpLoad] " & strSQL & " ORDER BY [ul_PostTime] DESC")
	Do While Not temprs.Eof
		If CheckRegExp(LCase(temprs("ul_FileName")),"\.(jpe?g|gif|bmp|png)$")=True And CheckRegExp(temprs("ul_FileName"),"%\d+")=False Then
			strResponse=BlogHost & ZC_UPLOAD_DIRECTORY &"/"&Year(temprs("ul_PostTime")) & "/" & Month(temprs("ul_PostTime")) & "/"&Server.URLEncode(temprs("ul_FileName"))
			Response.write "<div class=""ll""><a href=""javascript:try{window.opener.document.getElementById('tmp_image').value='"&strResponse&"'}catch(e){};window.close();"" title=""点击图片插入""><img src="""&strResponse&""" /></a></div>"& VBCRLF
		End If
		temprs.MoveNext
	Loop
	Set temprs=Nothing
ElseIf from = "windsphoto" Then
	Call WindsPhoto_Initialize
	Set temprs = objConn.Execute("SELECT TOP 100 url FROM WindsPhoto_desktop WHERE url NOT LIKE '%http%' ORDER BY id DESC")
	Do While Not temprs.Eof
		Response.write "<div class=""ll""><a href=""javascript:try{window.opener.document.getElementById('tmp_image').value='"&ZC_BLOG_HOST&"zb_users/plugin/windsphoto/"&temprs("url")&"';}catch(e){};window.close();"" title=""点击图片插入""><img src="""&WP_SUB_DOMAIN&temprs("url")&""" /></a></div>"& VBCRLF
		temprs.MoveNext
	Loop
	Set temprs=Nothing
End If
%>
</div>
</body>
</html>
<%Call System_Terminate()%>